<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>Title</title>
    <link rel="stylesheet" href="../script/bootstrap-3.3.7.min.css">
    <script src="../script/jquery-1.10.min.js"></script>
    <script>
        function display() {
            var a=1;
            var b
            b=2;
            var c=3,d=4
            e=5
            alert(a+b+c+d+e)
        }

                    //声明类型，
            var carname=new String;
            var x=      new Number;
            var y=      new Boolean;
            var cars=   new Array;
            var person= new Object;
            carname="cname";
            x=11;
            y=false;
            cars = ["rongwe","benz"];
            cars[2] = "BMW"
            var person={
                firstname : "John",
                lastname  : "Doe",
                id        :  5566
                };
        function display1() {
            if ( !y){
                alert(carname + x +"\n"+ cars +"\n"+ person.firstname)
            }
        }



    </script>
</head>
<body>
<div class="container">
    <div class="row">
    <div class="col-md-12">
        <p style="color: red;font-size: 1.5em;">数据类型： 字符串（String）、数字(Number)、布尔(Boolean)、数组(Array)、对象(Object)、空（Null）、未定义（Undefined）。</p>
    </div>
</div>
    <div class="row">
        <div>
            <textarea id = "text1" rows="8"></textarea>
            <script>
                str='var a=1; \n var bb=2; \n var c=3 \n d=4 \n e=5 \n alert(a+b+c+d+e)'
                document.getElementById("text1").value=str
            </script>
        </div>
    </div>
    <div class="row">
    <div class="col-md-6 col-md-offset-2">
        <div><button onclick="display()" class="btn btn-danger">执行</button></div>
    </div>
    </div>

    <p class="page-header"></p>

    <div class="row">
        <div>
            <textarea id = "text2" rows="20" cols="50"></textarea>
            <script>
                str='//声明类型，\n' +
                    'var carname=new String;\n' +
                    'var x=new Number;\n' +
                    'var y= new Boolean;\n' +
                    'var cars=new Array;\n' +
                    'var person= new Object;\n' +
                    'carname="cname";\n' +
                    ' x=11;\n' +
                    'y=false;\n' +
                    'cars = ["rongwe","benz"];\n' +
                    'cars[2] = "BMW"\n' +
                    'var person={\n' +
                    '                firstname : "John",\n' +
                    '                lastname  : "Doe",\n' +
                    '                id        :  5566\n' +
                    '                };\n' +
                    'function display1() {\n' +
                    '      if ( !y){\n' +
                    '          alert(carname + x +"\\n"+ cars +"\\n"+ person.firstname)\n' +
                    '       }\n' +
                    ' }\n'
                document.getElementById("text2").value=str
            </script>
        </div>
    </div>
    <div class="row">
    <div class="col-md-6 col-md-offset-2">
        <div><button onclick="display1()" class="btn btn-danger">执行</button></div>
    </div>
    </div>
</div>
<script>

   function changeimg() {

       // 三目运算 与上面 IF ELSE 效果一样
//       element.src=element.src.match("bulboff")?"img/pic_bulbon.gif":"img/pic_bulboff.gif"

       //jquery
//       element = $("#myimg")
//       console.log(element.attr("src"))
//       var newarry = ["img/pic_bulbon.gif"]
//       if ($.inArray(element.attr("src"),newarry))
//       {
//
//           element.attr("src","img/pic_bulbon.gif")
//       }
//       else
//       {
//           element.attr("src","img/pic_bulboff.gif")
//       }

   }

</script>
</body>
</html>